/*
 * Copyright GTEAM.,LTD.
 * All rights reserved.
 * 
 * This software is the confidential and proprietary information
 * of yysvip.tistory.com.,LTD. ("Confidential Information").
 */
package egovframework.home.web; 

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.support.SessionStatus;

import egovframework.com.bean.DefaultVO;
import egovframework.com.bean.GoodsVO;
import egovframework.com.util.Util;
import egovframework.goods.service.GoodsService;
import egovframework.rte.fdl.property.EgovPropertyService;

/**
 * <pre>
 * egovframework.home.web 
 *    └ AjaxController.java
 * 
 * </pre>
 * @date : 2014. 10. 12. 오후 3:50:54
 * @author : nimbi
 * @history : 
 *	-----------------------------------------------------------------------
 *	변경일				작성자						변경내용  
 *	----------- ------------------- ---------------------------------------
 *	2014. 10. 12.		nimbi				최초 작성 
 *	-----------------------------------------------------------------------
 * 
 */
@Controller
public class AjaxController {
	
	/** 상품 서비스 **/
	@Resource(name = "goodsService")
	private GoodsService goodsService;
	
	/** 유티릴티 모듈 */
    @Resource(name = "util")
    private Util util;
    
	/** 프로퍼티 서비스 */
    @Resource(name = "propertiesService")
    protected EgovPropertyService propertiesService;
    
	private Logger log = Logger.getLogger(this.getClass());

	@RequestMapping(value = "/AJAX/getGoodsCategory.do")
	public void getGoodsCate(
			GoodsVO goodsVO,
			HttpServletRequest request,
			SessionStatus status
	) throws Exception {
		String result = "";
		goodsVO.setTablename(propertiesService.getString("cate" + goodsVO.getDepth() + "tbl"));
		goodsVO.setSearchCondition(propertiesService.getString("cate" + goodsVO.getDepth() + "useyn"));
		goodsVO.setOrderby(propertiesService.getString("cate" + goodsVO.getDepth() + "seq"));
		if(goodsVO.getDepth() >= 2) {
			goodsVO.setSearchColumn("GCA_SN");
			goodsVO.setSearchKeyword(Integer.toString(goodsVO.getGcSn()));
		}
		@SuppressWarnings("unchecked")
		List<GoodsVO> cateList = (List<GoodsVO>)goodsService.selectGoodsCateList(goodsVO);
		if(cateList != null) result = cateList.toString();
		System.out.println(cateList.toString());
		System.out.println(result);
	}
}
